package networkinstance;

public class Main2 {
    public static void main(String[] args) {
        int size;
        try {
            java.net.URL url = new java.net.URL("http://www.runoob.com/wp-content/themes/runoob/assets/img/newlogo.png");
            java.net.URLConnection conn = url.openConnection();
            size = conn.getContentLength();
            if (size < 0)
                System.out.println("无法获取文件大小。");
            else
                System.out.println("文件大小为：" + size + " bytes");
            conn.getInputStream().close();
        } catch (java.io.IOException e) {
            throw new RuntimeException(e);
        }
    }
}
